package com.lc.afbx.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/6/6.
 */
@HttpInlet(Conn.INLET_API_INTEGRAL_RECORD)
public class GetApiRecord extends BaseAsyGet<GetApiRecord.Info> {
    public String userid;

    public GetApiRecord(AsyCallBack<GetApiRecord.Info> asyCallBack) {
        super(asyCallBack);
    }

    protected Info parser(JSONObject jsonObject) {

        TOAST = jsonObject.optString("message");

        if (jsonObject.optInt("code") == 200) {

            Info info = new Info();
            JSONArray array = jsonObject.optJSONArray("data");
            for (int i = 0; i < array.length(); i++) {

                JSONObject o = array.optJSONObject(i);
                Data d = new Data();

                d.id = o.optString("id");
                d.state = o.optString("state");
                d.posttime = o.optString("posttime");
                d.goodsname = o.optString("goodsname");
                d.integral = o.optString("integral");

                info.Data.add(d);
            }
            return info;
        }


        return null;
    }

    public static class Info {

        public List<Data> Data = new ArrayList<>();
    }

    public static class Data implements Serializable {

        //        "id": "1",
//                "state": "true",
//                "posttime": "1462863032",
//                "goodsname": "加油卡",
//                "integral": "30000"
        public String id;
        public String state;
        public String posttime;
        public String goodsname;
        public String integral;
    }


}
